-
Notifications
You must be signed in to change notification settings - Fork 320
add docs #263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
docs/_introduction.md
Outdated
| super(); | ||
| this.myProp='there'; | ||
| this.setTimeout(() => { | ||
| this.myProp='world'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spaces around = ?
docs/_site/index.html
Outdated
| <p>Learn more:</p> | ||
|
|
||
| <ul> | ||
| <li><a href="/try/">Try lit-element</a> without intalling anything.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo : intalling -> installing
docs/_introduction.md
Outdated
| ```js | ||
| render({}){ | ||
| return html` | ||
| <button on-click="${(e) => this._clickHandler(e)}"></button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is @click now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some information on what this is would be useful, as there is special handing in lit-html for that
docs/_introduction.md
Outdated
| <button on-click="${(e) => this._clickHandler(e)}"></button> | ||
| `; | ||
| } | ||
| _clickHander(e){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space before {
|
|
||
| </article> | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an excessive amount of newlines here
| this.project={}; | ||
| } | ||
| render(){ | ||
| var filenames=[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use var today :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I would add spaces around assignment as well as between () and { - that seems like common style
| } | ||
| render(){ | ||
| var filenames=[]; | ||
| if(this.project.files) var filenames=Object.keys(this.project.files); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as well as after if which isn't a function
| this.shadowRoot.getElementById('toggle').disabled = false; | ||
| } | ||
| async embedProject(project){ | ||
| var slot = this.shadowRoot.getElementById("slot"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const?
| this.loadProject(); | ||
| } | ||
|
|
||
| loadProject() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async loadProject and then use of async/await would make the below easier to read
| } | ||
|
|
||
| loadProject() { | ||
| if (this.folder == 'undefined') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the 's ?
docs/_site/docs/create/design.html
Outdated
| <li> | ||
| <a href="/try/">Try lit-element</a> | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is up with all these newlines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jekyll/Liquid does it. Will fix. :)
| @@ -0,0 +1,132 @@ | |||
| import {LitElement, html} from '@polymer/lit-element'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.bak, is this file meant to be here?
| } | ||
|
|
||
| } | ||
| ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This semicolon is probably unnecessary
|
|
||
| } | ||
|
|
||
| ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This semicolon is probably unnecessary as well
|
|
||
| embedProject(project, options) { | ||
| var embedIn = this.shadowRoot.getElementById('stackblitz'); | ||
| const vm = sdk.embedProject(embedIn, project, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vm doesn't seem to be used
docs/_introduction.md
Outdated
| Create custom elements that update on property changes. lit-element creates DOM once, then re-renders only the stuff that changed - making DOM updates lightning-fast. | ||
|
|
||
| ```js | ||
| static get properties(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space between () and {
|
@katejeffreys you may want to mention what part of this people should be reviewing. unless im mistaken, a lot of this is build output so shouldn't be code reviewed, rather the sources should. seems those are in |
docs/_introduction.md
Outdated
|
|
||
| ## React to property changes | ||
|
|
||
| Create custom elements that update on property changes. lit-element creates DOM once, then re-renders only the stuff that changed - making DOM updates lightning-fast. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the DOM?
docs/_site/index.html
Outdated
| <p><strong>Create fast, lightweight, reusable web components that work in any web page:</strong></p> | ||
|
|
||
| <div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">class</span> <span class="nx">MyElement</span> <span class="kd">extends</span> <span class="nx">LitElement</span><span class="p">{</span> | ||
| <span class="c1">// implemnt MyElement</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: implemnt -> implement
docs/_introduction.md
Outdated
|
|
||
| <a id="expressions"></a> | ||
|
|
||
| ## Use simple JavaScript expressions for loops and conditionals |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why simple? You can use advanced as well :-)
Use well-known JavaScript expressions for loops and conditionals
docs/_introduction.md
Outdated
|
|
||
| ## Use simple JavaScript expressions for loops and conditionals | ||
|
|
||
| Handling conditionals and loops in your lit-element templates is easy. No special annotations, just plain JavaScript expressions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/plain/regular?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think I'll just remove "plain"
docs/_introduction.md
Outdated
| <ul> | ||
| ${myArray.map(i => html`<li>${i}</li>`)} | ||
| </ul> | ||
| ${myBool? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add space before ? as well as before : - that makes it must easier to read and spot what you are doing
docs/_introduction.md
Outdated
| Use JavaScript expressions to add event listeners in plain HTML: | ||
|
|
||
| ```js | ||
| render({}){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think render takes arguments anymore
| return html` | ||
| <style> | ||
| :host, #staticsample { | ||
| min-height:50vh; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space after :
| <div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>import { LitElement, html } from '@polymer/lit-element'; | ||
|
|
||
| /** | ||
| * Anti-pattern. Avoid manipulating DOM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
manually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lit-html manipulates the DOM, so the anti-pattern is that people manually manipulate it
|
I opened #270 related to the formatting. If we figure that out we can run it again on the docs JS too. Until then though it looks like it'll mangle a lot of your html templates and what not 😢 |
docs/_includes/prevnext.html
Outdated
| <div class="prevnext"> | ||
| <div class="next"> | ||
| {%- if include.nexturl -%} | ||
| <a href="{{include.nexturl}}">Next: {{include.nexttitle}} >></a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e111077
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops disregard my review. I meant to leave that as a comment
|
|
||
| ```html | ||
| <head> | ||
| <script type="module" src="node_modules/package-name/existing-element.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest importing by name with inline script instead and let the tools will handle the resolution:
<script type=module>
import 'package-name/existing-element.js';
</script>This is what we did for PolymerElement demos (e.g. https://github.com/PolymerElements/iron-list/blob/master/demo/index.html#L20).
|
|
docs/src/stack-blitz.js
Outdated
| async loadProject() { | ||
| const folder = this.folder; | ||
| if (folder) { | ||
| const response = await fetch(`${folder}/manifest.json`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this have problems with multiple clicks? Can you disable the button and add visual feedback that the click was registered?
| <ul> | ||
| ${this.myArray.map(i => html`<li>${i}</li>`)} | ||
| </ul> | ||
| ${this.myBool? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest moving the ? and : to the begging of each result for better readability like so:
${this.myBool
? html`<p>Render some HTML if myBool is true</p>`
: html`<p>Render some other HTML if myBool is false</p>`
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this, will edit samples accordingly if I get time.
| `; | ||
| } | ||
| firstUpdated(changedProperties){ | ||
| console.log(changedProperties); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you doing console.log(changedProperties) here? It seems unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes I like to do console output to illustrate things to the reader. It's just a sample and they can ignore it if they want.
| `; | ||
| } | ||
| firstUpdated(changedProperties){ | ||
| console.log(changedProperties); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% on this but I believe you're supposed to call super.firstUpdated(changedProperties) when you use firstUpdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see anything to suggest this in the code or readme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, my bad
| } | ||
| changeMe(prop){ | ||
| var rand = Math.floor(Math.random()*100); | ||
| prop=='prop1'?this.prop1=rand:this.prop2=rand; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should either be an if statement or can be simplified into:
| prop=='prop1'?this.prop1=rand:this.prop2=rand; | |
| this[prop] = rand; |
| <!-- Style this text --> | ||
| <p class="${this.myBool?'red':'blue'}">style me</p> | ||
| <button @click="${(event) => this.clickHandler(event)}">Click</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems redundant to wrap a method in an arrow function. Instead you can just bind this.clickHandler:
| <button @click="${(event) => this.clickHandler(event)}">Click</button> | |
| <button @click="${this.clickHandler.bind(this)}">Click</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the recent "event context" addition, this should just be ${this.clickHandler} to avoid having to call .bind() each render. See #244
| <p>${this.message}</p> | ||
| <ul>${this.myArray.map(i => html`<li>${i}</li>`)}</ul> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of i here could be potentially confusing as i usually stands for index. Maybe it or text would be better here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, will edit
|
Closing this PR because it will be better to raise from Keanu's fork. |

Edit Nov 11 5pm
Thank you all for the feedback. I'm working on Keanu's fork for now: https://github.com/keanulee/lit-element/
The docs site is staged here: https://polymer-lit-element-staging.appspot.com/
docs: Main docs folder. gh-pages will build the docs site from Jekyll source in here. Only the source files (listed below) need review :)
These folders/files need review:
docs/_data: Jekyll yaml filesdocs/_includes/*.html: Jekyll templatesdocs/_layouts: Jekyll templatesdocs/css: Styles sourcedocs/docs: Markdown source for the API Documentation section of the sitedocs/projectsdocs/_includes/projects: Source files for embedded StackBlitz code samples.(This folder also gets copied* intodocs/_includes/.)docs/src: Source for the code to do the embedded StackBlitz samples.docs/tools: Markdown source for the Tools section of the site.docs/try: Markdown source for the "Try LitElement" tutorial section of the siteWhat is the other stuff & why is it here??
Other stuff is build output required for the docs site to run; doesn't need to be reviewed. E.g.
docs/_site: Generated Jekyll outputdocs/build: Build output - needed for StackBlitz to run in gh-pagesdocs/_includes/projects: Duplicate of content indocs/projectsbecause Jekyll can't find them if they're not here, and mysrc/*code can't find them if they are here. I need a better way of serving these files :)